namespace G1.EngineV
{
    using System;
    using Android.Graphics;

    public class Asset
    {

        public String Name { get; set; }
        
        private Android.Graphics.Bitmap[] _BitmapList;

        public int FrameCount { get; set; }
        public int FrameWidth { get; set; }
        public int FrameHeight { get; set; }

        public Asset( String Name, Android.Graphics.Bitmap Bitmap )
        {
            this.Name = Name;

            this._BitmapList = new Android.Graphics.Bitmap[1];

            this._BitmapList[0] = Bitmap;
            
            this.FrameCount = 0;
            this.FrameWidth = Bitmap.Width;
            this.FrameHeight = Bitmap.Height;

        }

        public Asset( String Name, Android.Graphics.Bitmap Bitmap, int FrameWidth, int FrameHeight, int FrameCount )
        {

            this.FrameCount = FrameCount;
            this.FrameWidth = FrameWidth;
            this.FrameHeight = FrameHeight;

            this.Name = Name;

            this._BitmapList = new Android.Graphics.Bitmap[FrameCount];

            for ( int i = 0; i < FrameCount; i++ )
            {

                _BitmapList[i] = Android.Graphics.Bitmap.CreateBitmap( FrameWidth, FrameHeight, Bitmap.GetConfig() );

                using ( Canvas Canvas = new Canvas( _BitmapList[i] ) )
                {
                    Canvas.DrawBitmap( Bitmap, new Rect( ( i * FrameWidth ), 0, ( i * FrameWidth ) + FrameWidth, FrameHeight ), new Rect( 0, 0, FrameWidth, FrameHeight ), null );
                }

            }


        }

        public Bitmap GetBitmap()
        {
            return this._BitmapList[0];
        }

        public Bitmap GetBitmap( int Frame )
        {
            return this._BitmapList[Frame];
        }

    }
}